<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page import="com.wframe.project.jnd.util.ServletUtils" %>
<%@ include file="/website/common/base.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>${webname }_专业的院外处方药采购平台，种类齐全、品质保障、贴心服务！</title>
	<meta name="description"
		  content="巨达药网judayw.com_广州巨孚达医药有限公司旗下的专业院外处方药采购平台，以处方药、新特药为核心品类，涵盖心脑血管、糖尿病、肝胆病等十多个专科用药，提供过万种药店畅销药。"/>
	<meta name="Keywords" content="药品采购,网上药品采购,处方药,新特药,心脑血管,糖尿病,药店畅销药,网上药店,网上买药,巨孚达,巨达药网,巨达"/>

	<%@ include file="/website/common/common.jsp" %>
	<link href="${webctx }/css/index.css" rel="stylesheet" type="text/css"/>
	<link href="${webctx }/css/sidebar.css?v=20170612" rel="stylesheet" type="text/css" />

	<style type="text/css">
		.img-bg-loading {
			background: url(${ctx}/website/images/loading.gif) no-repeat center center;
		}

		.img-bg-loading-blue {
			background: url(${ctx}/website/images/blue_loading.gif) no-repeat center center;
		}
	</style>

	<script src="${webctx }/js/Global.js"></script>
	<script src="${webctx }/js/index.js"></script>
</head>

<body onload="javascript:$('.img-bg-loading').removeClass('img-bg-loading');$('.img-bg-loading-blue').removeClass('img-bg-loading-blue');">
<%@ include file="/website/common/top.jsp" %>
<%@ include file="/website/common/head.jsp" %>
<%@ include file="/website/common/sidebar.jsp"%>
<jsp:include page="/website/common/menu.jsp?showclsnav=true&loadclsnav=false"/>

<div id="wrap-banner">
	<div class="slider-content img-bg-loading-blue" id="J_slider">
		<ul class="slider-main">
			<!-- 滚动广告图位置 -->
			<c:forEach var="info" items="${banners }">
				<li class="item-banner">
					<div>
						<a href="javascript:showInformation(${info.id },${info.type },'${info.url }');">
							<%
								String tempRandomFileserver = getRandomFileserver();
							%>
							<img src="<%=tempRandomFileserver%>/${info.phototitle}" class="hidden" style="z-index:1;"/>
							<img src="<%=tempRandomFileserver%>/${info.phototitle}" style="z-index:1;"/>
						</a>
					</div>
				</li>
			</c:forEach>
		</ul>
	</div>
	<div class="inner">
		<div class="nav-l-bd hide" id="clsnavmenu" style="top:0px;">
		</div>
	</div>
	<div class="vip-outcon">
		<div class="vipcon">
			<div class="vipcon-inf">
				<c:choose>
					<c:when test="${not empty user}">
						<div class="inf-hd">
							<span class="vip-pic" style="cursor:pointer" onclick="showusercenter()"><c:if test="${not empty user.photo}"><img src="${fileserver }${user.photo}" onerror="this.src='${webctx }/images/uhead.jpg'"/></c:if><c:if test="${empty user.photo}"><img src="${webctx }/images/uhead.jpg" /></c:if></span>
							<c:if test="${empty user.nickname }"><p style="padding-top:13px;">${user.loginname }</p></c:if>
							<c:if test="${ not empty user.nickname }"><p style="">${user.phone }</p><p style="">${user.nickname }</p></c:if>
						</div>
						<ul class="inf-mid1 clearfix">
							<li>
								<span class="mid1-l">优惠券</span><span class="mid1-r" onclick="qunima()">${usernum.couponnum }</span>
							</li>
							<li>
								<span class="mid1-l">积分</span><span class="mid1-r" onclick="qunimb()"><fmt:formatNumber value="${user.integral + user.ly_integral}" pattern="#0"/></span>
							</li>
						</ul>
						<ul class="inf-mid2 clearfix">
							<li>
								<a href="${ctx }/order/orderlist">我的订单<span>${ordernum.getInt("statussum") }</span>
								</a>
							</li>
							<li>
								<a href="${ctx }/order/orderlist?status=1">待付款<span>${ordernum.getInt("status1") }</span></a>
							</li>
							<li>
								<a href="${ctx }/order/orderlist?status=7" style="border-right:none">待收货<span>${ordernum.getInt("status7") }</span></a>
							</li>
						</ul>
						<ul class="inf-ft clearfix">
								<%--<li><a href="${ctx }/order/oftenList" class="t-1">常购清单<span></span></a></li>--%>
							<li><a href="${ctx }/product/favorites" class="t-4">收藏夹<span></span></a></li>
							<li><a href="${ctx }/purchasetemp/list" class="t-2">采购模板<span></span></a></li>
							<li><a href="${ctx }/order/loginhislistnew" class="t-3">历史采购<span></span></a></li>

						</ul>
					</c:when>
					<c:otherwise>
						<div class="login-hd">用户登录</div>
						<div class="login-bd">
							<form action="" method="post" onsubmit="tologin();return false">
								<div class="loginmsg"></div>
								<div class="bd-item">
									<div class="item-con">
										<span class="user-Ico"></span>
										<input id="wsc-username" name="loginname" type="text" class="item-inp" placeholder="请输入手机号/用户名"  onfocus="curinutfocus='login'" onblur="curinutfocus=''"/>
									</div>
								</div>
								<div class="bd-item">
									<div class="item-con">
										<span class="pass-Ico"></span>
										<input id="wsc-password" name="pwd" type="password" class="item-inp" placeholder="密码"  onfocus="curinutfocus='login'" onblur="curinutfocus=''"/>
									</div>
								</div>
								<div class="bd-item" style="height:34px;">
									<div class="yzm-inp"><input name="checkcode" type="text"  placeholder="请输入验证码"  onfocus="curinutfocus='login'" onblur="curinutfocus=''"/></div>
									<div class="yzm-pic"><img src="" onclick="getcheckcodeimg()" id="checkcodeimg" style="width:80px;height:33px;cursor:pointer"/></div>
								</div>
								<div class="bd-item-ft">
	                         <span class="fr">
								 <a href="javascript:showregisterpage();" class="col666">立即注册</a>
								 <%--<a href="${webctx }/user/findpwd.jsp" class="col666">忘记密码</a>--%>
							 </span>
									<span style="float: left;">
								<a href="${webctx}/user/findpwd.jsp" class="col666">忘记密码</a>
							</span>
								</div>
								<div class="bd-btn mt-30" style="padding-top:11px">
									<a href="javascript:tologin();" class="login-btn">登录</a>
								</div>
							</form>
						</div>
						<script>$(function () {
                            getcheckcodeimg();
                        })</script>
					</c:otherwise>
				</c:choose>
			</div>
			<div class="vipcon-news" id="J_news_tab">
				<div class="news-hd">
					<ul class="clearfix news-hd-main">
						<li class="cur" code="002002">最新资讯<span></span></li>
						<li code="002001">巨达公告</li>
					</ul>
					<span class="news-more"><a href="${ctx }/info/helplist">更多<font style="padding-left:4px;">></font></a></span>
				</div>
				<div class="news-bd">
					<ul class="item-bd">
						<s:infoList code="002002" psize="5">
							<li><a href="javascript:showInformation(${id },${type },'${url }');"><c:out value="${title }"></c:out></a></li>
						</s:infoList>
					</ul>
					<ul class="item-bd hide">
						<s:infoList code="002001" psize="5">
							<li><a href="javascript:showInformation(${id },${type },'${url }');"><c:out value="${title }"></c:out></a></li>
						</s:infoList>
					</ul>
				</div>
			</div>
		</div>
	</div>
</div>
<!--  -->
<div id="warp-container" style="background-color: #fff;">

	<!-- 今日特卖  -->
	<div id="todayFlashSale" style="display: none;" class="today-sale">
		<div class="sale-tit">
			<span>今日特卖</span>
			<div class="sale-nav">

			</div>
		</div>
		<div class="sale-con">
			<a class="sale-btn-prev" href="javascript:;"></a>
			<a class="sale-btn-next" href="javascript:;"></a>
			<div class="sale-con-list">
				<ul>
				</ul>
			</div>
		</div>
	</div>


	<!--喜欢推荐-->
	<div class="likePro inner mt-20" id="J_likePro_tab">
		<div class="likePro-hd">
			<ul class="likePro-hd-main">
				<li class="cur" type="hot"><i class="c-2"></i>热门推荐<span></span></li>
				<li type="maylike"><i class="c-1"></i>猜你喜欢</li>
			</ul>
			<ul class="likePro-hd-btn2">
				<li class="pagebtn"><i class="cur" id="likePro_p1"></i>/<i id="likePro_p2"></i></li>
				<li class="btn-prev" onclick="loadhotmay_prev()"></li>
				<li class="btn-next" onclick="loadhotmay_next()"></li>
			</ul>
		</div>
		<div class="likePro-bd">
			<ul class="likePro-bd-main" id="hotpush">

			</ul>

			<ul class="likePro-bd-main hide" id="maylike">

			</ul>
		</div>
	</div>

	<!--楼层-->
	<div id="floors"></div>

</div>
<%@ include file="/website/common/foot.jsp" %>
<script src="${ctx }/plugins/artTemplate/dist/template.js"></script>
<script>

    var flashSales_pagecount = 0;//总页数
    var flashSales_pageno = 0;//当前页码
    var flashSales_loadedpagecount = 0;//已加载页数
    var todayFlashSaleContainer = $("#todayFlashSale .sale-con .sale-con-list ul");
    var m_left = parseInt(todayFlashSaleContainer.css("margin-left")); //滚动距离

    var index = 0;
    var flashSalesDataUrl = apiroot + '/index/flashSales';

    function setFlashSalesData(fs) {
        if (fs) {

            for (var i = 0; i < fs.length; i++) {
                var fsItem = fs[i];

                var itemHtml = "";

                if( (i+1) % 5 == 0 ){
                    itemHtml += ("<li style='border-right: none;'>");
                } else {
                    itemHtml += ("<li>");
                }

                itemHtml += ("<a target='_blank' href='" + ctx + '/product/info?priceid=' + fsItem.pp_id + "'><img class='img-bg-loading' style='width:200px;height:200px;' onerror='this.src=\"" + ctx + "/website/images/noimg.jpg\";' src='" + getRandomFileserver() + fsItem.pic_photoview + "' alt=''>");

                if (fsItem.fs_amount <= 0) {
                    itemHtml += ("<span class='sm-mask'></span><span class='sm-mask-center'></span><i>已抢完</i>");
                }

                itemHtml += ("<p class='drug-name'>" + fsItem.pp_name + " " + fsItem.b_guige + "</p>");
                itemHtml += ("<p class='drug-company'>" + fsItem.b_chanjia + "</p>");
                if (fsItem.pm_promotion_type == 0) {

                    if (fsItem.can_promotion == 1) {
                        itemHtml += ("<p class='drug-price'>" + ((isuserauth && islogin) ? "¥" + fsItem.fs_price + "<span>￥" + fsItem.pr_price + "</span>" : (!islogin ? "登录可见" : "审核通过可见")) + "</p>");
                    } else {
                        itemHtml += ("<p class='drug-price'>" + ((isuserauth && islogin) ? "¥" + fsItem.pr_price : (!islogin ? "登录可见" : "审核通过可见")) + "</p>");
                    }

                    if (fsItem.fs_amount <= 0) {
                        itemHtml += ("<p class='drug-overtime'><em>" + fsItem.fs_sold_amount + "</em> 件单品已抢完啦！</p>");
                    } else {
                        if (fsItem.fs_count_down == 1) {
                            itemHtml += ("<p endTime='" + fsItem.pm_surplus_seconds + "' class='drug-overtime'></p>");
                        }
                        else {
                            itemHtml += ("<p class='drug-overtime'>活动火热进行中</p>");
                        }
                    }
                }
                if (fsItem.pm_promotion_type == 1) {

                    if (fsItem.can_promotion == 1) {
                        itemHtml += ("<p class='drug-price'>" + ((isuserauth && islogin) ? "¥" + fsItem.pr_price + "<span></span>" : (!islogin ? "登录可见" : "审核通过可见")) + "</p>");
                    } else {
                        itemHtml += ("<p class='drug-price'>" + ((isuserauth && islogin) ? "¥" + fsItem.pr_price : (!islogin ? "登录可见" : "审核通过可见")) + "</p>");
                    }
                    if (fsItem.can_promotion == 1) {
                        itemHtml += ("<p class='drug-overtime'>买<em>" + fsItem.bs_buy_number + " </em>送<em> " + fsItem.send_number + "</em></p>");
                    }

                }
                itemHtml += ("</a>");
                itemHtml += ("</li>");
                todayFlashSaleContainer.append(itemHtml);

            }
        }
    }

    function nextFlashSalesPage() {
        if (flashSales_loadedpagecount >= flashSales_pagecount) {
            //数据已加载过
            m_left = m_left - 1200;
            index = index + 1;
            if (index >= flashSales_pagecount) {
                index = flashSales_pagecount - 1;
                m_left = -(flashSales_pagecount - 1) * 1200;
            }
            $(".sale-nav span").removeClass("cur").eq(index).addClass("cur");
            todayFlashSaleContainer.css("margin-left", m_left);

        } else {
            //数据未加载过去远程获取
            $w.httpRequest({
                url: flashSalesDataUrl,
                data: {
                    "pageno": (flashSales_pageno + 1)
                },
                ok: function (ret) {
                    if (ret.Data.list && (flashSales_pageno + 1) == ret.Data.pageno) {
                        flashSales_pageno = ret.Data.pageno;
                        flashSales_loadedpagecount++;
                        setFlashSalesData(ret.Data.list);
                    }
                }
            });
            m_left = m_left - 1200;
            index = index + 1;
            $(".sale-nav span").removeClass("cur").eq(index).addClass("cur");
            todayFlashSaleContainer.css("margin-left", m_left);
        }
    }

    $(function () {

        $w.httpRequest({
            url: flashSalesDataUrl,
            data: {
                "pageno": 1
            },
            ok: function (ret) {

                if (ret.Data.list) {
                    flashSales_pagecount = ret.Data.pagecount;
                    flashSales_pageno = ret.Data.pageno;
                    flashSales_loadedpagecount = flashSales_pageno;

                    setFlashSalesData(ret.Data.list);

                    if ($("#todayFlashSale .sale-con .sale-con-list ul").children().length > 0) {
                        initFlashSales();
                        $("#todayFlashSale").css("display", "block");
                    }

                }
            }
        });

        var flashSaleTimeInterval = window.setInterval(function () {
            var drugOvertimeItems = $(".drug-overtime[endTime]");
            if (drugOvertimeItems.length > 0) {
                drugOvertimeItems.each(function () {
                    var endTime = $(this).attr("endTime");
                    if (endTime > 0) {
                        var h = parseInt(endTime / (60 * 60));//小时
                        var m = parseInt(endTime / 60 % 60);//分钟
                        var s = parseInt(endTime % 60); //秒
                        $(this).html("还剩：<span>" + h + "</span> 时 <span>" + m + "</span> 分 <span>" + s + "</span> 秒");
                        endTime--;
                        $(this).attr("endTime", endTime);
                    } else {
                        $(this).html("活动已截止");
                        $(this).removeAttr("endTime");
                    }
                });
            } else {
                window.clearInterval(flashSaleTimeInterval);
            }
        }, 1000);

    });

    function initFlashSales() {
        var nav = $(".sale-nav");//导航圆点
        var prev = $(".sale-btn-prev")//上一页
        var next = $(".sale-btn-next")//下一页

        var h = "";
        for (var i = 0; i < flashSales_pagecount; i++) {
            h += "<span></span>";
        }
        nav.append(h);//添加圆点
        nav.find("span:first-child").addClass("cur");//给第一个圆点加默认状态cur

        //	//下一页
        next.click(function () {
            nextFlashSalesPage();
        })
        //    //上一页
        prev.click(function () {
            m_left = m_left + 1200;
            index = index - 1;
            if (index < 0) {
                index = 0;
                m_left = 0;
            }
            $(".sale-nav span").removeClass("cur").eq(index).addClass("cur");
            todayFlashSaleContainer.css("margin-left", m_left);
        })

    }
    ;

</script>
</body>
</html>